import 'package:enterprise_v6_app/app/components/special_operation/custom_select_function.dart';
import 'package:enterprise_v6_app/app/core/core.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_scence_safe_appliance_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_scence_safe_third_assess_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_scence_safe_third_continue_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_scence_safe_third_inspect_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standard_scence_safe_third_work_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/application/standardiztion/standardization_entity.dart';
import 'package:enterprise_v6_app/app/modules/application/standardization/pages/scence/work_safe/model.dart';

/// 作业安全
class StandardizationScenceSafeController extends GetxController {
  var type = StandardizationSafeMenuType.all.first;

  Future<List<StandardizationEntity>> getPages(int idx, int size, {String? search}) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardizationEntity>>(
      '${Interface.mainBaseUrl}${type.path}',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  /// 劳保用品
  Future<List<StandardScenceSafeApplianceEntity>> getLaobao(int idx, int size, {String? search}) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardScenceSafeApplianceEntity>>(
      '${Interface.mainBaseUrl}${type.path}',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  /// 三方资质审查记录
  Future<List<StandardScenceSafeThirdInspectEntity>> getShenCha(int idx, int size, {String? search}) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardScenceSafeThirdInspectEntity>>(
      '${Interface.mainBaseUrl}${type.path}',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  /// 三方作业过程检查
  Future<List<StandardScenceSafeThirdWorkEntity>> getProcess(int idx, int size, {String? search}) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardScenceSafeThirdWorkEntity>>(
      '${Interface.mainBaseUrl}${type.path}',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  /// 三方绩效评估
  Future<List<StandardScenceSafeThirdAssessEntity>> getAssess(int idx, int size, {String? search}) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardScenceSafeThirdAssessEntity>>(
      '${Interface.mainBaseUrl}${type.path}',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  /// 三方续用退出记录
  Future<List<StandardScenceSafeThirdContinueEntity>> getContinue(int idx, int size, {String? search}) async {
    final resp = await HttpUtil().generateGetRequest<List<StandardScenceSafeThirdContinueEntity>>(
      '${Interface.mainBaseUrl}${type.path}',
      queryParameters: {
        'pageNum': idx,
        'pageSize': size,
        'name': search,
      },
    ).execute();
    return resp.data ?? [];
  }

  void showSelect() {
    CustomSelectFunction.selectMultipleBottomSheet<StandardizationSafeMenuType>(
      onCallBack: (val) {
        type = val.first;
        update();
      },
      dataList: StandardizationSafeMenuType.all,
      checkedList: [type],
      isMultiple: false,
    );
  }
}
